import Taro, { Component } from '@tarojs/taro'
import { View, Button, SwiperItem, Text } from '@tarojs/components'
import styles from './index.module.scss'
import classNames from 'classnames'
import {FyImg} from "@/components/index";
import SeckillGoodsBg from '@/assets/images/seckill-goods-bg.png'
import { toGoodsPage } from '@/utils/page_router'
/**
 * 秒杀商品列表
 */
interface IProps {
  list: any
}
export default class Index extends Component<IProps, {}> {
  props: any
  state: any

  constructor() {
    super(...arguments)
    this.state = {
    }
  }

  componentWillReceiveProps() {
  }

  render() {
    const { list } = this.props

    return (list.length ? <View className={styles.goodsList}>
      {list.map(item => {
        return (<View className={styles.goodsItem} onClick={() => toGoodsPage(item)}>
          <FyImg src={item.images[0]} className={styles.goodsItemImg}/>
          <View className={styles.goodsItemContent}>
            <View className={classNames(styles.name, 't-o-e')}>{item.name}</View>
            <View className={classNames(styles.subTitle, 'd-f', 'j-c-b')}>
              <View className={styles.subTitleItem}>限时特价</View>
              <View className={styles.subTitleItem}>每人限购{item.limitNumber}件</View>
            </View>
            <View className={styles.price}>
              <FyImg src={SeckillGoodsBg} className={styles.goodsBg}/>
              <View className={classNames(styles.originPrice, 'd-f', 'j-c-b')}>
                <s>￥{Number(item.originPrice)}</s>
                <s>￥{Number(item.originPrice) + 24}</s>
              </View>
              <View className={classNames(styles.salePriceBox, 'f-g-5')}>
                <View className={styles.salePrice}>秒杀价￥{Number(item.salePrice)}</View>
              </View>
            </View>
          </View>
        </View>)
      })}
    </View> : null)
  }
}
